package cn.bonoon.kernel.menus;

import cn.bonoon.kernel.VisibleLevel;
import cn.bonoon.kernel.support.IOperator;

/**
 * <pre>
 * 追加在每个子系统首页的子独立的子菜单；
 * 
 * 注意：不能通过权限控制来限制用户的访问操作权限
 * </pre>
 * @author jackson
 *
 */
public class PartDefinition implements Comparable<PartDefinition>{
	public static final int 
			LEVEL_USER  = 0B00000001,
			LEVEL_ADMIN = 0B00000010, 
			LEVEL_SUPER = 0B00000100;
	
	private String url;
	private String name;
	private int ordinal;
	private String iconCls;
	private boolean helper;
	
	private VisibleLevel level;
	//public PartInfo(){}

	public PartDefinition(String name, String url){
		this.name = name;
		this.url = url;
	}
	
	@Override
	public int compareTo(PartDefinition o) {
		return ordinal = o.ordinal;
	}
	
	public boolean checked(IOperator user) {
		return level.accept(user);
	}
	
	public String getUrl() {
		return url;
	}
	
	public void setUrl(String url) {
		this.url = url;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	public int getOrdinal() {
		return ordinal;
	}
	public void setOrdinal(int ordinal) {
		this.ordinal = ordinal;
	}
	public String getIconCls() {
		return iconCls;
	}
	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}
	public VisibleLevel getLevel() {
		return level;
	}
	public void setLevel(VisibleLevel level) {
		this.level = level;
	}

	public boolean isHelper() {
		return helper;
	}

	public void setHelper(boolean helper) {
		this.helper = helper;
	}
}
